using Serilog;
using Serilog.Events;

var builder = WebApplication.CreateBuilder(args);

builder.Host.UseSerilog((context, configuration) =>
{
    //configuration.WriteTo.Console()
    //.WriteTo.File(path: "E:\\projects\\logger-using\\ApiUsingSerilog\\bin\\Debug\\net8.0\\Logs\\logs-.txt",
    //rollingInterval: RollingInterval.Day
    ////, formatter: new CompactJsonFormatter()
    //).MinimumLevel.Override("Microsoft.AspNetCore", LogEventLevel.Warning)
    //;
    configuration.ReadFrom.Configuration(context.Configuration);
});
// Add services to the container.

builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();

var app = builder.Build();
app.UseSerilogRequestLogging(); // <-- Add this line

// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
    app.UseSwagger();
    app.UseSwaggerUI();
}

app.UseAuthorization();

app.MapControllers();

app.Run();
